
package unicamp.redes.rmi;

import java.io.IOException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 * start the server component. this exposes the an implementation of the Compute interface as a service over RMI
 * 
 * @author srasul
 * 
 */
public class ServerStarter
    extends RmiStarter {
    
    public ServerStarter() throws IOException {
        super(Dac.class);
    }

    @Override
    public void doCustomRmiHandling() {
        try {
            Dac dac = new DacImpl();
            Dac dacStub = (Dac)UnicastRemoteObject.exportObject(dac, 0);

            Registry registry = LocateRegistry.getRegistry();
            registry.rebind(Dac.SERVICE_NAME, dacStub);
        }
        catch(Exception e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) throws IOException {
        new ServerStarter();
    }
}
